package cn.xiuxius.askbox.controller.common;
import cn.xiuxius.askbox.pojo.dto.common.RegisterDTO;
import cn.xiuxius.askbox.pojo.result.Result;
import cn.xiuxius.askbox.pojo.vo.CaptchaVO;
import cn.xiuxius.askbox.pojo.vo.RegisterVO;
import cn.xiuxius.askbox.service.ICommonService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Api(tags = "通用-验证码接口")
@RestController
@RequestMapping("/commons/captcha")
public class CaptchaController {

    @Autowired
    private ICommonService commonService;


    @ApiOperation("获取登录验证码")
    @GetMapping("/login")
    public Result getLoginCaptcha(){
        CaptchaVO captcha =  commonService.getCaptcha();
        return Result.success(captcha);
    }

    @ApiOperation("发送注册验证码")
    @GetMapping("/register")
    public Result getRegisterCaptcha(@Validated RegisterDTO registerDTO){
        RegisterVO vo = commonService.getRegisterCaptcha(registerDTO);
        return Result.success(vo);
    }

}
